﻿@model IEnumerable<QuanLyGiaoVuUI.Models.ThongBao.ThongBaoViewModel>

@{
    ViewBag.Title = "ThongBaoGiaoVuDaGui";
    Layout = "~/Views/Shared/_blueWhaleLayout.cshtml";
}

@{Html.RenderPartial("ThongBaoMenuPartial");}

<div id="main" class="grid_10 gvclientmain">
    <!--  start page-heading -->

    <div id="page-heading" class="box round first grid">
        <h2>Các thông báo đã gửi</h2>
        <!-- end page-heading -->
        <div id="gvclientmaincontent" class="block">
             <div id="#actionBar">
                <input type="button" id="btnThongBaoMoi" value="Thông báo mới" onclick="ThongBaoObject.TaoThongBaoMoi()" />
            </div>
            <div id="dsThongBaoDaGui"></div>
        </div>
    </div>
</div>

<div class="clear">&nbsp;</div>

<div id="ThongBaoMoiDialog"></div>

<script>
    $(document).ready(function () {
        $("input[type=button]").button();
        ThongBaoObject.CapNhatDanhSachDaGui();
    });
    
    var ThongBaoObject = new function () {
        this.TaoThongBaoMoi = function () {
            $("#ThongBaoMoiDialog").load("/ThongBao/TaoThongBao").dialog({
                autoOpen: true,
                modal: true,
                title: "Thông báo mới",
                width: 753,
                height: 600,
                buttons: {
                    "Gửi thông báo": function () {
                        $("#guiThongBao-submit").trigger("click");
                        ThongBaoObject.CapNhatDanhSachDaGui();
                    },
                    "Hủy bỏ": function () {
                        $("#ThongBaoMoiDialog").dialog("close");
                    }
                }
            });
        }

        this.ChonNguoiNhan = function () {
            $("#ChonNguoiNhanDialog").dialog("open");
        }

        this.CapNhatDanhSachDaGui = function () {
            $.ajax({
                url: "/ThongBao/DanhSachThongBaoDaGui",
                type: "GET",
                success: function (data) {
                    $("#dsThongBaoDaGui").html(data);
                }
            });
        }
    }
</script>
